package com.tianma315.admin.util;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Name;

public class HiddenSheetUtil {
    public static void initHiddenSheet(String sheetName, HSSFWorkbook wb,Integer cellNum,
                                  Integer startRow, Integer endRow, String[] strArr){
        HSSFSheet category1Hidden = wb.createSheet(sheetName);
        for (int i = 0, length = strArr.length; i < length; i++) { // 循环赋值（为了防止下拉框的行数与隐藏域的行数相对应来获取>=选中行数的数组，将隐藏域加到结束行之后）
            category1Hidden.createRow(endRow + i).createCell(cellNum).setCellValue(strArr[i]);
        }
        Name category1Name = wb.createName();
        category1Name.setNameName(sheetName);
        // A1:A代表隐藏域创建第?列createCell(?)时。以A1列开始A行数据获取下拉数组
        category1Name.setRefersToFormula(sheetName + "!A1:A" + (strArr.length + endRow));
    }
}
